﻿@model PurchaseOrders
@section ToolBar{}
<div class="l-m-form">
    <span>@ViewBag.CompanyName</span>
    <form mark="LedinghuoForm" action="@Url.Action("Receivables")" method="POST">
        <div class="form-item l-m-table form l-margin-t20">
            <table id="PurchaseOrderList">
                <tr class="bgc3">
                    <th rowspan="2">采购单号</th>
                    <th rowspan="2">订单日期</th>
                    <th rowspan="2">订单金额</th>
                    <th rowspan="2">已付款</th>
                    <th rowspan="2">应付款</th>
                    <th colspan="4" class="t-c h20">付款记录</th>
                </tr>
                <tr>
                    <th class="h20">付款时间</th>
                    <th class="h20">金额</th>
                    <th class="h20">付款方式</th>
                    <th class="h20">备注</th>
                </tr>

                @{
                    int i = 0;
                    foreach (PurchaseOrder e in Model.Items)
                    {
                        int count = e.PurchaseOrderCapitals.Items.Count + 2;
                        <tr>
                            <td rowspan="@count">@Html.LActionLink(e.PurchaseOrderNo, "Detail", "PurchaseOrder", new { id = e.PurchaseOrderId }, new { single = "single" })</td>
                            <td rowspan="@count">@e.CreateTime.TimeFormat()</td>
                            <td rowspan="@count">@e.ActualAmount.MoneyFormat()</td>
                            <td rowspan="@count">@e.SettleedAmount.MoneyFormat()</td>
                            <td rowspan="@count">@e.UnSettleedAmount.MoneyFormat()</td>

                        </tr>
                        foreach (PurchaseOrderCapital item in e.PurchaseOrderCapitals.Items)
                        {
                            <tr>
                                <td>@item.CapitalTime.TimeFormat()</td>
                                <td>@item.Amount.MoneyFormat()</td>
                                <td>@item.PaymentType.PaymentTypeName</td>
                                <td>@item.Remark</td>
                            </tr>
                        }
                        if (!e.IsCompleted || e.SettleStatusId != SettleStatus.SettleedComplete)
                        {
                            <tr index="@i">
                                <td><input type="text" class="inp-text full" name="CapitalTime_@i" value="@DateTime.Now.TimeFormat()" /></td>
                                <td><input type="text" class="inp-text full" name="Amount_@i" /></td>
                                <td>
                                    <input name="PaymentTypeBox_@i" id="PaymentTypeBox_@i" type="text" class="inp-text full bc1 bgc0 inp-lg7 inp-hg6 commonbox" fa="fa-angle-down" readonly="readonly" />
                                    <input type="hidden" name="PaymentTypeId_@i" id="PaymentTypeId_@i" />
                                </td>
                                <td>
                                    <input type="text" class="inp-text full" name="Remark_@i" />
                                    @Html.Hidden("PurchaseOrderId_" + i, e.PurchaseOrderId)
                                </td>
                            </tr>
                        }
                        i++;
                    }
                    @Html.Hidden("PurchaseOrderCapitalCount", i);
                }
            </table>
            @Html.Hidden("ProviderId", (long)ViewBag.ProviderId)
        </div>
        @Html.LButton("确定收款")
    </form>
    @Html.LPageError()
</div>


<script type="text/javascript">
    $(function () {
        $("#PurchaseOrderList").find("tr[index]").each(function () {
            var $self=$(this);
            $self.find("input[name^=PaymentTypeBox_]").paymentType(function ($this, $s) {
                var index = $s.attr("name").split("_")[1];
                $self.find("input[name=PaymentTypeId_" + index + "]").val($this.attr("data"));
            });
        });
    });
</script>




